#!/bin/bash

# 项目根目录
root_dir="$(cd "$(dirname "$0")" && pwd)"
img_exts="png jpg jpeg gif svg"
src_img="$root_dir/image.png"
target_dir="$root_dir/images"
count=0

mkdir -p "$target_dir"

for ext in $img_exts; do
  find "$root_dir" -type f \( -iname "*.$ext" \) ! -path "$src_img" ! -path "$target_dir/*" | while read -r img; do
    fname=$(basename "$img")
    cp -rf "$src_img" "$target_dir/$fname"
    count=$((count+1))
  done
done

total=$(ls "$target_dir" | wc -l)

echo "被替换的图片数量: $total"
echo "目标输出目录: ./images/"
